# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libpeas
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.22.0
pkgrel=2
pkgdesc="A GObject-based plugins engine (mingw-w64)"
arch=('any')
url="https://www.gtk.org/"
license=("LGPL2")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-glade"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-python3-gobject"
             "${MINGW_PACKAGE_PREFIX}-python2-gobject"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "intltool")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
        )
options=('strip' 'staticlibs')
install=${_realname}-${CARCH}.install
source=(https://download.gnome.org/sources/${_realname}/${pkgver:0:4}/${_realname}-${pkgver}.tar.xz
        0004-localedir-fix.patch)
sha256sums=('5b2fc0f53962b25bca131a5ec0139e6fef8e254481b6e777975f7a1d2702a962'
            'e428b0e009777602b106e00b115cfe5d5fc141027c7f57a5c69ddd7c50361cea')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0004-localedir-fix.patch

  autoreconf -fi
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --sysconfdir=${MINGW_PREFIX}/etc \
    --localstatedir=${MINGW_PREFIX}/var \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --enable-shared \
    --enable-python2 \
    --enable-python3 \
    --enable-glade-catalog \
    --enable-gtk \
    --enable-gtk-doc

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
